#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> missingTwo(vector<int>& nums) {
        int ret = 0;
        for (auto a : nums)
            ret ^= a;
        for (int i = 1; i <= nums.size() + 2; i++)
            ret ^= i;

        int d = 0;
        while (true)
        {
            if (((ret >> d) & 1) == 1) break;
            else d++;
        }

        int x = 0, y = 0;
        for (auto a : nums)
            if (((a >> d) & 1) == 1)
                x ^= a;
            else
                y ^= a;
        for (int i = 1; i <= nums.size() + 2; i++)
            if (((i >> d) & 1) == 1)
                x ^= i;
            else
                y ^= i;
        return { x,y };
    }
};